import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { useI18n } from '/@/hooks/web/useI18n';
import { log } from 'console';
const { t } = useI18n('device.tagManagement.fields');
const tagManagementFields = {
  tagId: t('tag_id'),
  count: t('count'),
  barcode: t('barcode'),
  isallocate: t('isallocate'),
  use_state: t('use_state'),
  tag_type: t('tag_type'),
  EAS_lock_state: t('EAS_lock_state'),
  FAI_lock_state: t('FAI_lock_state'),
  data_area: t('data_area'),
  description: t('description'),
  batch: t('batch'),
  production_time: t('production_time'),
  visits: t('visits'),
};
//列表数据
export const columns: BasicColumn[] = [
  {
    title: tagManagementFields.tagId,
    align: 'center',
    dataIndex: 'tagId',
    fixed: 'left',
  },
  {
    title: tagManagementFields.count,
    align: 'center',
    dataIndex: 'count',
  },
  {
    title: tagManagementFields.barcode,
    align: 'center',
    dataIndex: 'barcode',
  },
  {
    title: tagManagementFields.isallocate,
    align: 'center',
    dataIndex: 'isallocate',
    customRender: ({ text }) => {
      if (text === '1') {
        return t('yes');
      }
      return t('no');
    },
  },
  {
    title: tagManagementFields.use_state,
    align: 'center',
    dataIndex: 'useState',
    customRender: ({ text }) => {
      if (text === '1') {
        return t('use');
      }
      return t('unuse');
    },
  },
  {
    title: tagManagementFields.tag_type,
    align: 'center',
    dataIndex: 'tagType',
  },
  {
    title: tagManagementFields.EAS_lock_state,
    align: 'center',
    dataIndex: 'easLockStatus',
    customRender: ({ text }) => {
      return render.renderDict(text, 'EAS_lock_state', true);
    },
  },
  {
    title: tagManagementFields.FAI_lock_state,
    align: 'center',
    dataIndex: 'faiLockStatus',
    customRender: ({ text }) => {
      return render.renderDict(text, 'FAI_lock_state', true);
    },
  },
  {
    title: tagManagementFields.data_area,
    align: 'center',
    dataIndex: 'dataArea',
  },
  {
    title: tagManagementFields.description,
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: tagManagementFields.batch,
    align: 'center',
    dataIndex: 'batch',
  },
  {
    title: tagManagementFields.production_time,
    align: 'center',
    dataIndex: 'productiveTime',
  },

  {
    title: tagManagementFields.visits,
    align: 'center',
    dataIndex: 'visits',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: tagManagementFields.tagId,
    field: 'tagId',
    component: 'JInput',
    // colProps: { span: 6 },
    // componentProps: { type: 'like' },
  },
  {
    label: tagManagementFields.barcode,
    field: 'barcode',
    component: 'JInput',
    // colProps: { span: 6 },
    // componentProps: { type: 'like' },
  },
  {
    label: tagManagementFields.isallocate,
    field: 'useState',
    component: 'Select',
    componentProps: {
      checkedValue: '1',
      unCheckedValue: '0',
      options: [
        { label: '使用', value: '1' },
        { label: '未使用', value: '0' },
      ],
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: tagManagementFields.tagId,
    field: 'tagId',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: t('alert') + ' ' + tagManagementFields.tagId }];
    },
    colProps: { span: 12 },
  },

  {
    label: tagManagementFields.barcode,
    field: 'barcode',
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.isallocate,
    field: 'isallocate',
    component: 'Switch',
    componentProps: {
      checkedValue: '1',
      unCheckedValue: '0',
    },
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.use_state,
    field: 'useState',
    component: 'Switch',
    componentProps: {
      checkedValue: '1',
      unCheckedValue: '0',
    },
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.count,
    field: 'count',
    component: 'InputNumber',
    componentProps: {
      min: 1,
    },
    dynamicRules: () => {
      return [{ required: true, message: t('alert') + ' ' + tagManagementFields.count }];
    },
    colProps: { span: 12 },
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.tag_type,
    component: 'Input',
    field: 'tagType',
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.EAS_lock_state,
    component: 'JDictSelectTag',
    field: 'easLockStatus',
    colProps: { span: 12 },
    componentProps: {
      dictCode: 'EAS_lock_state',
    },
  },
  {
    label: tagManagementFields.FAI_lock_state,
    component: 'JDictSelectTag',
    field: 'faiLockStatus',
    colProps: { span: 12 },
    componentProps: {
      dictCode: 'FAI_lock_state',
    },
  },
  {
    label: tagManagementFields.data_area,
    component: 'Input',
    field: 'dataArea',
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.description,
    component: 'Input',
    field: 'description',
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.batch,
    component: 'Input',
    field: 'batch',
    colProps: { span: 12 },
  },
  {
    label: tagManagementFields.production_time,
    component: 'DatePicker',
    field: 'productiveTime',
    colProps: { span: 12 },
  },
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
